/*
 * Copyright (C) 2013 SeekDeepWithin.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package com.seekdeepwithin.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Jonathan Montiverdi
 * Date: Sep 24, 2013
 *
 * Represents a sub book.
 */
public class SubBook extends Book
{
   private int m_Order;
   private int m_LinkedSubBookListId = -1;
   private final int m_SubBookListId;
   private final Book m_ParentBook;
   private List<Chapter> m_Chapters;

   /**
    * Initializes a new sub book, copying data from the given book.
    * @param copyBook Book to copy data from.
    * @param subBookListId The ID of the book in the sub book list.
    * @param parentBook The parent book this sub book belongs to.
    */
   public SubBook (Book copyBook, int subBookListId, Book parentBook)
   {
      super (copyBook);
      this.m_SubBookListId = subBookListId;
      this.m_ParentBook = parentBook;
      this.m_Chapters = new ArrayList<> ();
   }

   /**
    * Initializes a new sub book object.
    * @param title Title of sub book.
    * @param id ID of sub book.
    * @param subBookListId The ID of the book in the sub book list.
    * @param parentBook The parent book this sub book belongs to.
    */
   public SubBook (String title, int id, int subBookListId, Book parentBook)
   {
      super (title, id);
      this.m_SubBookListId = subBookListId;
      this.m_ParentBook = parentBook;
   }

   /**
    * Gets the order of the sub book.
    * @return The Sub Book's order.
    */
   public int getOrder ()
   {
      return this.m_Order;
   }

   /**
    * Set the Sub Book's order.
    * @param order Order of sub book.
    */
   public void setOrder (int order)
   {
      this.m_Order = order;
   }

   /**
    * Gets the ID of sub book in the sub book list.
    * @return ID of sub book in the sub book list.
    */
   public int getSubBookListId ()
   {
      return this.m_SubBookListId;
   }

   /**
    * Gets the parent book.
    * @return The book that contains this sub book.
    */
   public Book getParentBook ()
   {
      return this.m_ParentBook;
   }

   /**
    * Gets the linked sub book list id.
    * @return The linked sub book list id.
    */
   public int getLinkedId ()
   {
      return this.m_LinkedSubBookListId;
   }

   /**
    * Sets the linked sub book list id.
    * @param linkedId The linked sub book list id.
    */
   public void setLinkedId (int linkedId)
   {
      this.m_LinkedSubBookListId = linkedId;
   }

   /**
    * Gets the list of chapters.
    * @return A list of chapters.
    */
   public List<Chapter> getChapters ()
   {
      return this.m_Chapters;
   }
}
